<template>
  <header class="header" >
      <h1>todos</h1>
      <input class="new-todo" placeholder="请输入内容" @keyup.13="enterUp" v-model="inVal" />
  </header>
</template>
<script>
  export default {
    name:'Header',
    data(){
      return {
        inVal:this.$store.state.inputValue
      }
    },
    methods:{
      enterUp(){
        if(this.inVal == '') return;
        this.$store.commit('enter',{
          title: this.inVal,
          id: Date.now(),
          checked: false
        })
        this.inVal = '';
      }
    }
  }
</script>
